using System.Collections;
using System.Collections.Generic;
using UnityEngine;

namespace PAL
{
    public class PALResources
    {
        private static PALResources _ins = null;

        public static PALResources Ins
        {
            get
            {
                if (_ins == null)
                {
                    _ins = new PALResources();
                }

                return _ins;
            }
        }

        private List<PALResInfo> ResInfos = new List<PALResInfo>
        {
            new PALResInfo {source = "PALData/abc", bufferName = ResType.ABC},
            new PALResInfo {source = "PALData/ball", bufferName = ResType.BALL},
            new PALResInfo {source = "PALData/data", bufferName = ResType.DATA},
            new PALResInfo {source = "PALData/f", bufferName = ResType.F},
            new PALResInfo {source = "PALData/fbp", bufferName = ResType.FBP},
            new PALResInfo {source = "PALData/fire", bufferName = ResType.FIRE},
            new PALResInfo {source = "PALData/gop", bufferName = ResType.GOP},
            new PALResInfo {source = "PALData/m", bufferName = ResType.MSG},
            new PALResInfo {source = "PALData/map", bufferName = ResType.MAP},
            new PALResInfo {source = "PALData/mgo", bufferName = ResType.MGO},
            new PALResInfo {source = "PALData/pat", bufferName = ResType.PAT},
            new PALResInfo {source = "PALData/rgm", bufferName = ResType.RGM},
            new PALResInfo {source = "PALData/rng", bufferName = ResType.RNG},
            new PALResInfo {source = "PALData/sss", bufferName = ResType.SSS},
            new PALResInfo {source = "PALData/voc", bufferName = ResType.VOICE},
            new PALResInfo {source = "PALData/desc", bufferName = ResType.DESC},
            new PALResInfo {source = "PALData/word", bufferName = ResType.WORD},
            new PALResInfo {source = "PALData/wor16.asc", bufferName = ResType.ASCII},
            new PALResInfo {source = "PALData/wor16.fon", bufferName = ResType.FONT},
        };

        public Dictionary<string, byte[]> ResBuffers = new Dictionary<string, byte[]>();

        public void Load()
        {
            foreach (var v in ResInfos)
            {
                ResBuffers.Add(v.bufferName, Resources.Load<TextAsset>(v.source).bytes);
                Debug.Log(ResBuffers[v.bufferName].Length);
            }
        }
    }

    public class PALResInfo
    {
        public string source;
        public string bufferName;
    }
}